<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html>
<html class="x-admin-sm">
    
    <head>
    	<base href="<%=basePath%>">
        <meta charset="UTF-8">
        <title>欢迎页面-X-admin2.2</title>
        <meta name="renderer" content="webkit">
	    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
        <link rel="stylesheet" href="<%=basePath %>leyuiyc/css/font.css">
        <link rel="stylesheet" href="<%=basePath %>leyuiyc/css/xadmin.css">
        <script type="text/javascript" src="<%=basePath %>leyuiyc/lib/layui/layui.js" charset="utf-8"></script>
        <script type="text/javascript" src="<%=basePath %>leyuiyc/js/xadmin.js"></script>
        <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
        <!--[if lt IE 9]>
            <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
            <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
        <![endif]-->
    </head>
<body>
	<div class="layui-fluid">
		<div class="layui-row layui-col-space15">
			<div class="layui-col-md12">
				<div class="layui-card">
					<div class="layui-card-body ">
						<table class="layui-table layui-form" id="test" lay-filter="test">
						</table>
						<input class="fileupload-input" id="goodsCommonId" type="hidden" name="picpath" value="${goodsCommonId }"/>
						<input class="fileupload-input" id="goods_name" type="hidden" name="picpath" value="${goodsName }"/>
					</div>
				</div>
			</div>
		</div>
	</div>
	<script>
				layui.use(['table','form','slider','layedit', 'laydate', "jquery"], function(){
				  var form = layui.form
				  ,layer = layui.layer
				  ,layedit = layui.layedit
				  ,laydate = layui.laydate
				  ,slider = layui.slider
				  ,table = layui.table
				  ,$ = layui.jquery;
		  			var text1 = $("#goods_name").val();
				  table.render({
				    elem: '#test'
				    ,url:'inventory/findInventory.do?goods_name='+text1
				    ,width: 'auto'
				    ,height: 400
				    ,method: 'post'
				    ,toolbar: '#toolbarDemo'
				    ,title: '订单信息表'
				    ,page: true
				    ,cols: [[
			    	   {type:'checkbox', fixed: 'left'}
				      ,{field:'area_name', width:130, title: '所属服务点'}
				      ,{field:'goods_id', width:130, title: '商品ID'}
				      ,{field:'goods_name', width:90, title: '商品名称'}
				      ,{field:'is_normal', width:80, title: '商品类型',align:'center',templet:'#m_type'}
				      ,{field:'specifications', width:80, title: '商品规格',align:'center'}
				      ,{field:'goods_storage', width:80, title: '库存数量'}
				      ,{field:'goods_destine_quota', width:180, title: '采购数量', edit: 'text', style:'background-color: #009688; color: #fff;'}
				    ]]
				    ,skin: 'row' //表格风格
	                ,limits:[10,20,30,40,50]
				    ,limit: 20 //每页默认显示的数量
				  });
				  //头工具栏事件
				  table.on('toolbar(test)', function(obj){
				    var checkStatus = table.checkStatus(obj.config.id); //获取选中行状态
				    switch(obj.event){
				      case 'getCheckData':
				        var data = checkStatus.data;  //获取选中行数据
				        	var num = 0;
					        console.log(data[0].goods_destine_quota);
					        var array = new Array();
					        var array2 = new Array();
					        var array3 = new Array();
					        for (i = 0; i < data.length; i++) { 
					        	num += Number(data[i].goods_destine_quota)
					        	array.push(data[i].goods_id)
					        	array2.push(data[i].is_normal)
					        	array3.push(data[i].goods_destine_quota)
					        }
	                    	var text2 = $("#goodsCommonId").val();
	                    	var ar = JSON.stringify(array);
	                    	var ar2 = JSON.stringify(array2);
	                    	var ar3 = JSON.stringify(array3);
	                    	var storage = window.sessionStorage;
	                    	  storage.setItem('num', num);
	                    	  storage.setItem('ar', ar);
	                    	  storage.setItem('goodsCommonId', text2);
	                    	  storage.setItem('ar2', ar2);
	                    	  storage.setItem('ar3', ar3);
	                    	  storage.setItem('service_point_id', data[0].service_point_id);
	                    	 xadmin.father_reload();//对父页面进行刷新
						    var index = parent.layer.getFrameIndex(window.name);  
						    parent.layer.close(index);
						    break;
				      break;
				    };
				  });
			 });
				</script>
				<script type="text/html" id="toolbarDemo">
   					 <button class="layui-btn layui-btn-sm" lay-event="getCheckData">确定</button>
				</script>
				<script type="text/html" id="m_type">	
	    	{{#  if(d.is_normal == "0") {  }}
				<font color="#00ff00">正品</font>
			{{#  } else if(d.is_normal == "1") {  }}
				<font color="#ff0000">打折</font>
        	 {{#  } else if(d.is_normal == "2") {  }}
				<font color="#ff0000">体验</font>
			{{#  } else if(d.is_normal == "3") {  }}
				<font color="#ff0000">积分兑换</font>
			{{#  } else if(d.is_normal == "4") {  }}
				<font color="#ff0000">用来打包</font>
			{{#  } else if(d.is_normal == "7") {  }}
				<font color="#ff0000">可兑换打包品</font>
			{{#  }  }}
    </script>
</body>

</html>
